package com.example.math;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class ThirdScreen extends Activity implements OnClickListener {
	TextView headerText, textScreenTwo;
	Button homeBtn;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.screen_three);
		getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
				R.layout.titlebar);
		Bundle extras = getIntent().getExtras();
		if (getIntent().getExtras() != null
				&& getIntent().hasExtra("SecondScreenItem")) {
			String textFromScreenTwo = extras.getString("SecondScreenItem");
			textScreenTwo = (TextView) findViewById(R.id.text);
			textScreenTwo.setText(textFromScreenTwo);

		}

		homeBtn = (Button) findViewById(R.id.home_btn);
		headerText = (TextView) findViewById(R.id.header_txt);
		headerText.setText("Screen Three");
		homeBtn.setOnClickListener(this);
		findViewById(R.id.button1).setOnClickListener(this);
		findViewById(R.id.button2).setOnClickListener(this);
		findViewById(R.id.button3).setOnClickListener(this);
		findViewById(R.id.button4).setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.button1:
			finish();
			break;

		case R.id.home_btn:

			Intent intentHome = new Intent(this, FirstScreen.class);
			startActivity(intentHome);
			break;
		case R.id.button2:

			Intent intentBtn2 = new Intent(this, FourthScreen.class);
			Bundle b = new Bundle();
			Button b1 = (Button) findViewById(R.id.button2);
			String selectedButton = b1.getText().toString();
			b.putString("ThirdScreenItem", selectedButton);
			intentBtn2.putExtras(b);
			startActivity(intentBtn2);
			break;
		case R.id.button3:

			Intent intentBtn3 = new Intent(this, FourthScreen.class);
			Bundle b_3 = new Bundle();
			Button b3 = (Button) findViewById(R.id.button3);
			String selectedButton3 = b3.getText().toString();
			b_3.putString("ThirdScreenItem", selectedButton3);
			intentBtn3.putExtras(b_3);
			startActivity(intentBtn3);
			break;
		case R.id.button4:

			Intent intentBtn4 = new Intent(this, FourthScreen.class);
			Bundle b_4 = new Bundle();
			Button b4 = (Button) findViewById(R.id.button4);
			String selectedButton4 = b4.getText().toString();
			b_4.putString("ThirdScreenItem", selectedButton4);
			intentBtn4.putExtras(b_4);
			startActivity(intentBtn4);
			break;

		default:
			Intent intent_two = new Intent(this, FourthScreen.class);
			startActivity(intent_two);
			break;
		}
	}

}
